package com.menchao.carsales.controller;

import com.menchao.carsales.common.http.Const;
import com.menchao.carsales.pojo.Employee;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * Porject: carsales
 * Date: 2021/7/12
 * Author: menchao
 * Description:
 */

@RestController
public class TestController {

    @RequestMapping("/test")
    public String helloCarSales(HttpSession session){
        System.out.println("TestController ....");

        String dateStr = (String) session.getAttribute("seesionKey");
        System.out.println("session dateStr: " + dateStr);
        System.out.println("sessionId: " + session.getId());

        if (dateStr == null){
            Date date = new Date();
            session.setAttribute("seesionKey", date.toString());
        }

        return "hello CarSales! " + session.getId();
    }

}
